const fs = require("fs");
const path = require("path");

export const urlRoutes = () => {
  let urls = [];
  const pathName = "/Users/ruoshui/Desktop/project/tally-admin/src/views";
  let files = fs.readdirSync(pathName);
  files.forEach((item) => {
    fs.stat(path.join(pathName, item), (err, data) => {
      if (data.isFile()) {
        urls.push({ path: item, component: item });
        fs.appendFile("./appRouter.json", urls, (error) => {
          if (err) {
            console.log("追加文件失败", err.message);
            return;
          }
          console.log("追加成功");
        });
      }
    });
  });
};
